<template>
    <div class="query_tool">
        <div class="item">
            <span class="lable">会员姓名</span>
            <div class="value">
                <el-input v-model="queryValue.name" placeholder="请输入会员名称" clearable />
            </div>
        </div>
        <div class="item">
            <span class="lable">会员手机</span>
            <div class="value">
                <el-input v-model="queryValue.phone" placeholder="请输入会员手机号" clearable />
            </div>
        </div>
        <el-button @click="queryList" type="primary" size="medium">查询</el-button>
        <el-button @click="openDialog" type="warning" size="medium">新增</el-button>
    </div>
    <div class="content">
        <el-table :data="tableData" style="width: 100%">
            <el-table-column prop="id" label="ID" width="80"> </el-table-column>
            <el-table-column prop="name" label="姓名" width="180"></el-table-column>
            <el-table-column prop="phone" label="手机号" width="180"></el-table-column>
            <el-table-column prop="paytotal" label="消费总数" width="100"></el-table-column>
            <el-table-column prop="integral" label="现有积分" width="100"></el-table-column>
            <el-table-column prop="remarks" label="备注"></el-table-column>
            <el-table-column fixed="right" label="操作" width="180">
                <template v-slot="scope">
                    <el-button @click="edit(scope.row)" type="text">编辑</el-button>
                    <el-divider direction="vertical" />
                    <el-button @click="$emit('openRecord', scope.row)" type="text">消费记录</el-button>
                    <el-divider direction="vertical" />
                    <delButton @del="dele(scope.row.id)" />
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                :hide-on-single-page="true"
                background
                layout="prev, pager, next"
                v-model:currentPage="page.current"
                @currentChange="getList"
                :total="page.total">
        </el-pagination>
    </div>
    <UserDialog ref="dialogDom" :title="dialogTitle" @ok="getList" />
</template>

<script>
import delButton from '../../components/del-button.vue'
import UserDialog from './UserDialog.vue'
import { querySetup } from "./UserQuery";
import { getUser, deleUser } from '../../api/api.js'
import { setupDialog } from "../Commodity/setupDialog";

export default {
    name: 'User',
    emits: ['openRecord'],
    components: { UserDialog, delButton },
    setup(props, refs) {
        const queryOtion = querySetup(getUser, deleUser)
        const dialogData = setupDialog('新增会员', '编辑会员')
        return {
            ...queryOtion,
            ...dialogData,
        }
    }
}
</script>

<style lang="less" scoped>
@import "../../assets/css/queryTool.less";
</style>
